package mviewer.renderer.software;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.Map;
import java.util.Stack;
import mviewer.renderer.software.core.Matrix3d;
import mviewer.renderer.software.interfaces.IBuffer;
import mviewer.renderer.software.interfaces.ILighting;
import mviewer.renderer.software.interfaces.IPerspective;
import mviewer.types.Camera;
import mviewer.types.IModel3d;
import mviewer.types.IPolygon;
import mviewer.types.IVertex;

public class WireframeDrawer extends SimpleSoftwareDrawer {

	public WireframeDrawer(ILighting lighting, IPerspective perspective,
			Camera camera, IBuffer buffer, Graphics2D graphics,
			Stack<Matrix3d> matrices, Map<String, IModel3d> modelInstances) {
		super(lighting, perspective, camera, buffer, graphics, matrices, modelInstances);
	}

	@Override
	protected void drawPolygon(IPolygon polygon, int xOffset, int yOffset) {
		IVertex[] v = polygon.getVertices();
		int[] x = new int[v.length], y = new int[v.length];

		for (int i = 0; i < v.length; i++) {
			x[i] = (int) v[i].getX() + xOffset;
			y[i] = (int) v[i].getY() + yOffset;
		}

		super.drawPolygon(polygon, xOffset, yOffset);
		graphics.setColor(Color.WHITE);
		graphics.drawPolygon(x, y, v.length);
	}

}
